home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4880 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.6 KB  |  61 lines

  1. Newsgroups: comp.lang.c++,comp.lang.pascal.delphi.misc
  2. Path: news.clark.net!bms88!stuart
  3. From: stuart@bmsi.com (Stuart D. Gathman)
  4. Subject: Re: C++ with Zapp vs. Delphi
  5. Organization: Business Management Systems, Inc., Fairfax, VA
  6. Date: Wed, 31 Jan 1996 03:58:39 GMT
  7. Message-ID: <1996Jan31.035839.11567@bmsi.com>
  8. References: <4dk38h$gdr@merlin.delphi.com> <4dksp1$3d6c@tigger.cc.uic.edu> <4e1i7t$v29@klein.delphi.com>
  9.  
  10. In article <4e1i7t$v29@klein.delphi.com> you write:
  11. >>If you have MI it's easy. Just create a class called SortedObject with
  12. >>a virtual method called CompareTo. Store objects of that type in the list.
  13. >
  14. >     Abstract method in Delphi.
  15. >
  16. >>An class that need to get stored can then inherit from SortedObject.
  17. >>Unfortunately you can't use this in Delphi since you know some of the
  18. >>classes already inherit from something else.
  19. >
  20. >     You can to do this! Look at TStrings!
  21. >
  22. >>If your language is dynamically typed, it's easy. In the sort routine
  23. >>send the message CompareTo. Unfortunatly Delphi is statically typed.
  24. >
  25. >     Just CALL it!  (Declare an Abstract!)
  26. >
  27. >     Either we are miscommunicating, and one of us does not understand the
  28. >other, or both, but it seems to me you may want to check into Delphi a little
  29. >more.
  30. >
  31. >     If I am not understanding you, excuse me.  I can read C, but am by no
  32. >means a C expert.
  33.  
  34. Hi!   C++ uses the same inheritance mechanism for both interfaces
  35. and implementation.  A C++ only person has trouble realizing that
  36. just  because a language provides SI implementation, that doesn't
  37. prevent it from providing MI interfaces.
  38.  
  39. Something similar to abstract methods in Delphi appears as an ex-
  40. tension  in  GNU  C++.  There they are called signatures.  Signa-
  41. tures have their own inheritance hierarchy independent  of  stan-
  42. dard  class  inheritance.   One  can  attach a signature to *any*
  43. class providing the required methods - regardless of inheritance.
  44. They  are implemented as a pointer to the real object and a vtble
  45. that forwards all signature methods to the real object.
  46.  
  47. Java also follows this pattern.  SI plus MI interfaces.  It has a
  48. lot to recommend it.  Forces you to keep interface and implementation
  49. seperate.
  50.  
  51. Again, the C++ people you are talking to are correct in insisting
  52. that MI is essential in C++ - this is the only way an object can
  53. conform to multiple interfaces!  It is a leap for C++ers to realize
  54. that classic inheritance is not the only way to provide an
  55. interface.
  56. -- 
  57. Stuart D. Gathman    <stuart@bmsi.com> / <..!uunet!bms88!stuart>
  58.                 Business Management Systems Inc.
  59.                Phone: 703 591-0911 Fax: 703 591-6154
  60.           "Microsoft is the QWERTY of Operating Systems" - SDG
  61.